//
//  MessageDetailTableViewCell.m
//  51易借
//
//  Created by apple on 2017/9/20.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "MessageDetailTableViewCell.h"

@implementation MessageDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setModel:(MessageListModel *)model
{
    _model = model;
    self.titleLabel.text = model.name;
    self.timeLabel.text = [Lahelper formattedTimeFromTimeInterval:[model.createTime longLongValue] formatted:@"yyyy-MM-dd HH:mm:ss"];
    self.contentLabel.attributedText = [self lineSpaceStringWithString:model.content andLineSpace:7];
//    self.accountLabel.text = model.userAccount;
    self.accountLabel.text = @"";
}

-(void)setNotice:(NoticeListModel *)notice
{
    _notice = notice;
    self.titleLabel.text = notice.name;
    self.timeLabel.text = [Lahelper formattedTimeFromTimeInterval:[notice.announceTime longLongValue] formatted:@"yyyy-MM-dd HH:mm:ss"];
    self.contentLabel.attributedText = [self lineSpaceStringWithString:notice.content andLineSpace:7];
    self.accountLabel.text = notice.createBy;
}

-(NSMutableAttributedString*)lineSpaceStringWithString:(NSString *)content andLineSpace:(CGFloat)lineSpace
{
    NSMutableParagraphStyle * style = [[NSMutableParagraphStyle alloc] init];
    [style setLineSpacing:lineSpace];
    NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:content?content:@"     "];
    [string addAttributes:@{NSParagraphStyleAttributeName:style} range:NSMakeRange(0, string.length)];
    return string;
}

@end
